/*
${' '}* Copyright ${.now?string('yyyy')} The JA-SIG Collaborative. All rights reserved.
${' '}* distributed with this file and available online at
${' '}*/
package ${basePackage}.adapter.driven.web.${module};<#lt>

import ${basePackage}.application.${module}.${className}AppService;
import ${basePackage}.application.${module}.command.Create${className}Cmd;
import ${basePackage}.application.${module}.command.Update${className}Cmd;
import ${basePackage}.application.${module}.query.Query${className}PageQuery;
import ${basePackage}.application.${module}.query.${className}Dto;

import com.lap.framework.dto.page.PageResponse;
import com.lap.watchdog.starter.annotation.RepeatSubmit;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 提供${tableComment}restful接口层:
 *
 * <ol>
 *  <li>业务规则，原则上不做任何业务逻辑处理，仅仅是技术入口
 *  <li>命名规则，语义上明确接口做什么，推荐使用 Restful 命名 + Verb风格方法名（适配Swagger、Spring）:
 *    <ul>
 *     <li>分页使用 getXXXPage
 *     <li>获取单个 getXXById
 *     <li>保存使用 createXX
 *     <li>更新使用 updateXX
 *     <li>删除使用 deleteXX
 *    </ul>
 * </ol>
 *
 * @author  ${author!'generator'}
 * @version ${version!'0.1.0'}
 */
@Tag(name = "${tableComment}管理", description = "提供${tableComment}基本操作，查询等")
@RequiredArgsConstructor
@RestController
@RequestMapping("api/v1/${mapping!''}")
public class ${className}Controller {

  private final ${className}AppService ${lowerName}AppService;

  @Operation(summary = "获取${tableComment}")
  @GetMapping
  public PageResponse<${className}Dto> get${className}Page(Query${className}PageQuery query) {
    return ${lowerName}AppService.query${className}sByPage(query);
  }

  @Operation(summary = "添加${tableComment}")
  @RepeatSubmit
  @PostMapping
  public Integer create${className}(@RequestBody @Valid Create${className}Cmd cmd) {
    return ${lowerName}AppService.create${className}(cmd);
  }

  @Operation(summary = "更新${tableComment}")
  @RepeatSubmit
  @PutMapping("{id}")
  public Integer update${className}(@PathVariable Integer id, @RequestBody @Valid Update${className}Cmd cmd) {
    return ${lowerName}AppService.update${className}(id, cmd);
  }

  @Operation(summary = "删除${tableComment}")
  @RepeatSubmit
  @DeleteMapping("{id}")
  public Integer deleteDictType(@PathVariable Integer id) {
    return ${lowerName}AppService.deleteDictType(id);
  }
}